using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using MediaOwl.Common;
using MediaOwl.Common.ScreenManagement;
using MediaOwl.LastFm.Resources;

namespace MediaOwl.LastFm.ViewModels
{
    [Export(typeof(IWorkspace))]
    public sealed class LastFmViewModel : Workspace<IWorkitem<IWorkspace>>
    {
        #region Constructor
        [ImportingConstructor]
        public LastFmViewModel([ImportMany(AllowRecomposition = true)] IEnumerable<IWorkitem<LastFmViewModel>> childScreens)
        {
            ChildScreens = childScreens as IEnumerable<IWorkitem<IWorkspace>>;
            DisplayName = Captions.ModuleTitle;
            Order = 1;
            IconName = Captions.MenuTitle;
            Icon = new ImageBrush
                       {
                           ImageSource =
                               new BitmapImage(new Uri(@"/MediaOwl.LastFm;component/Resources/Images/MusicIcon.png", UriKind.Relative))
                       };

            FillItems();
        }

        #endregion

        protected override void OnInitialize()
        {
            base.OnInitialize();

            var msg =
                Show.MessageBox(
                    "No LastFm-Key found. In order to use this module, you must enter a LastFm-Api-Key into LastFmDataAccess.resx!")
                    .In<IShell>();

            Run.Coroutine(msg);
        }
    }
}